home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
varia
/
interp18.lha
/
interp-1.8
/
Symbol.cc
< prev
next >
Wrap
C/C++ Source or Header
|
1990-01-20
|
3KB
|
122 lines
// Symbol.cc -- the definition of the member functions for class Symbol.
// Copyright (C) 1989 Carey Richard Murphey.
// (rich@rice.edu) 5310 Rutherglenn, Houston, TX 77096
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 1, or (at your option)
// any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "Symbol.h"
#if !defined(__OPTIMIZE__) || defined(INLINE)
#ifndef INLINE
#define INLINE
#endif
// class Symbol::
INLINE void Symbol:: assign (double p)
{
cerr << "Error: Cannot assign to this symbol.\n";
}
INLINE void Symbol:: assign (int p)
{
cerr << "Error: Cannot assign to this symbol.\n";
}
INLINE Symbol:: operator double ()
{
cerr << " Error: This symbol has no value.\n";
return 0.;
}
INLINE Symbol:: operator int ()
{
cerr << " Error: This symbol has no value.\n";
return 0;
}
INLINE double Symbol:: func (double p)
{
cerr << " Error: This symbol is not a function.\n";
return 0.;
}
INLINE ostream& operator << (ostream& Stream, Symbol* p)
{
return p->echo (Stream);
}
// class Double_Pointer::
INLINE void Double_Pointer:: assign (double p)
{
*v.double_p = p;
}
INLINE void Double_Pointer:: assign (int p)
{
*v.double_p = (double) p;
}
INLINE Double_Pointer:: operator double ()
{
return *v.double_p;
}
INLINE Double_Pointer:: operator int ()
{
return (int) *v.double_p;
}
INLINE int Double_Pointer:: type ()
{
return 2;
}
INLINE ostream& Double_Pointer:: echo (ostream& Stream)
{
return Stream << *v.double_p;
}
// class Int_Pointer::
INLINE void Int_Pointer:: assign (double p)
{
*v.int_p = (int) p;
}
INLINE void Int_Pointer:: assign (int p)
{
*v.int_p = p;
}
INLINE Int_Pointer:: operator double ()
{
return *v.int_p;
}
INLINE Int_Pointer:: operator int ()
{
return *v.int_p;
}
INLINE int Int_Pointer:: type ()
{
return 3;
}
INLINE ostream& Int_Pointer:: echo (ostream& Stream)
{
return Stream << *v.int_p;
}
// class Function::
INLINE double Function:: func (double p)
{
return (*v.t_func_p)(p);
}
INLINE int Function:: type ()
{
return 4;
}
INLINE ostream& Function:: echo (ostream& Stream)
{
return Stream << "double function (double arg)";
}
#endif